@extends('admin.layout.layout')
@section('content')
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <input type="hidden" name="cate_id" value="{{$cateinfo->cate_id}}">
                    <div class="layui-form-item">
                        <label for="L_cate_pid" class="layui-form-label">
                            上级分类id</label>
                        <div class="layui-input-inline">
                            <input type="text" name="cate_pid" class="layui-input" value="{{$cateinfo->cate_pid}}" placeholder="请输入上级分类id" >
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red">*</span>0为默认顶级栏目
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_cate_name" class="layui-form-label">
                            <span class="x-red">*</span>分类名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_cate_name" name="cate_name" value="{{$cateinfo->cate_name}}" required="" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_cate_title" class="layui-form-label">
                            <span class="x-red">*</span>分类别名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_cate_title" name="cate_title" value="{{$cateinfo->cate_title}}" required="" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit="">修改</button></div>
                </form>
            </div>
        </div>
        <script>layui.use(['form', 'layer','jquery'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
                //监听提交
                form.on('submit(add)',function(data) {
                    $.ajax({
                        url: '{{url("admin/category")}}/'+data.field.cate_id,
                        type: 'PUT',
                        data:{
                            '_token':'{{csrf_token()}}',
                            cate_id:data.field.cate_id,
                            cate_pid:data.field.cate_pid,
                            cate_name:data.field.cate_name,
                            cate_title:data.field.cate_title
                        },
                        dataType:'json',
                        success: function(res) {
                            if(res.status == 0){
                                //发异步，把数据提交给php
                                layer.alert(res.message, {
                                        icon: 6
                                    },
                                    function() {
                                        //关闭当前frame
                                        xadmin.close();

                                        // 可以对父窗口进行刷新
                                        xadmin.father_reload();
                                    });
                            }else {
                                layer.msg(res.data[0]);
                            }
                        }
                    });
                    return false;
                });

            });</script>
@endsection